package com.hzlj.position.locate.converter;

import com.hzlj.position.locate.common.dto.reportInspectionAutoSetting.ReportInspectionAutoSettingAddDTO;
import com.hzlj.position.locate.common.dto.reportInspectionAutoSetting.ReportInspectionAutoSettingQueryResultDTO;
import com.hzlj.position.locate.common.dto.reportInspectionAutoSetting.ReportInspectionAutoSettingUpdateDTO;
import com.hzlj.position.locate.common.model.ReportInspectionAutoSetting;
import com.fz.common.base.converter.ModelDTOConverter;
import com.fz.common.base.core.date.DateUtils;

/**
 * 通信联络核查-核查-自动配置表(ReportInspectionAutoSetting)DTO转换类
 *
 * @author lifh
 * @date 2023-03-16 09:46:01
 */
public class ReportInspectionAutoSettingConverter {
    /**
     * model实例转换为查询结果DTO
     *
     * @param model model实例
     * @return DTO
     */
    public static ReportInspectionAutoSettingQueryResultDTO from(ReportInspectionAutoSetting model) {
        return ModelDTOConverter.from(model, ReportInspectionAutoSettingQueryResultDTO.class);
    }

    /**
     * 新增DTO转换为model实例
     *
     * @param dto 新增DTO
     * @return model实例
     */
    public static ReportInspectionAutoSetting from(ReportInspectionAutoSettingAddDTO dto) {
        return ModelDTOConverter.from(dto, ReportInspectionAutoSetting.class, (ReportInspectionAutoSetting l) -> {
            l.setValid(true);
            l.setUpdateTime(DateUtils.now());
            l.setCreateTime(DateUtils.now());
        });

    }

    /**
     * 修改DTO转换为model实例
     *
     * @param dto 修改DTO
     * @return model实例
     */
    public static ReportInspectionAutoSetting from(ReportInspectionAutoSettingUpdateDTO dto) {
        return ModelDTOConverter.from(dto, ReportInspectionAutoSetting.class, (ReportInspectionAutoSetting l) -> {
            l.setUpdateTime(DateUtils.now());
        });
    }
}
